using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System.IO;

namespace PackTool
{
    public class AssetExportEx
    {
        [MenuItem("Assets/PackTool/Prefab")]
        public static void PrefabExport()
        {
            bool b = false;
            if (Selection.gameObjects.Length != 0)
            {
                b = true;
                ResourcesExport.Clear();
            }

            List<GameObject> prefabs = new List<GameObject>();
            foreach (GameObject go in Selection.gameObjects)
            {
                prefabs.Add(ResourcesExport.ExportPrefab(go, false));
            }

            if (b == true)
            {
                ComponentData.SaveObjList();
                ComponentData.SavePrefabs();
            }

            foreach (GameObject go in prefabs)
                ResourcesExport.DeleteCopyPrefab(go);
        }

        [MenuItem("Assets/PackTool/PrefabAll")]
        public static void PrefabAllExport()
        {
            if (Selection.activeGameObject)
            {
                ResourcesExport.Clear();
                ResourcesExport.Export(Selection.activeGameObject, ".ap", BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets | BuildAssetBundleOptions.DeterministicAssetBundle);
            }
        }

        [MenuItem("Assets/PackTool/AnimationExport")]
        public static void AnimationExport()
        {
            if (Selection.activeObject as AnimationClip)
            {
                ResourcesExport.Clear();
                ResourcesExport.ExportAnim(Selection.activeObject as AnimationClip);
            }
        }
    }
}